/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.user.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.pig4cloud.pigx.common.core.util.R;
import com.pig4cloud.pigx.user.dto.UpdateCapitalAccountDTO;
import com.pig4cloud.pigx.user.entity.CapitalAccount;
import com.pig4cloud.pigx.user.entity.RechargeRecord;
import com.pig4cloud.pigx.user.entity.User;
import com.pig4cloud.pigx.user.vo.LoginUserCapitalVO;

import java.math.BigDecimal;
import java.util.List;

/**
 * 资金账户
 *
 * @author pigx code generator
 * @date 2022-11-21 17:40:27
 */
public interface CapitalAccountService extends IService<CapitalAccount> {

	/**
	 * 用户注册时生成资金账户
	 * @param user user
	 */
	void createCapital(User user);

	/**
	 * 获取当前登陆人的资金账户
	 * @return r
	 */
	R<LoginUserCapitalVO> getUserCapital();

	/**
	 * 人工充值 修改资金账户
	 * @param dto dto
	 * @return r
	 */
	R<String> updateByAdmin(UpdateCapitalAccountDTO dto);

	/**
	 * 充值成功后修改资金账户余额
	 * @param record 充值记录
	 */
	void rechargeThen(RechargeRecord record);

	/**
	 * 获取用户资金账户
	 * @param userId 用户id
	 * @param currency 币种
	 * @return 账户信息
	 */
	CapitalAccount getUserBalance(Long userId,String currency);

	/**
	 * 获取用户资金账户
	 * @param list 用户id
	 * @param currency 币种
	 * @return 账户信息
	 */
	List<CapitalAccount> getUserBalance(List<User> list, String currency);

	/**
	 * 修改用户资金余额
	 * @param userId 用户id
	 * @param currency 币种
	 * @param balance 修改额度
	 * @param isAdd true 增加  false 减少
	 * @param isFrozen true 奖励  false 不是奖励
	 */
	void updateBalance(Long userId, String currency, BigDecimal balance, boolean isAdd,boolean isFrozen);

}
